<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache"/>   
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate"/>   
<meta http-equiv="expires" content="0"/>  
<title>服务热线设置</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/select.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.idTabs.min.js"></script>
<script type="text/javascript" src="js/select-ui.min.js"></script>
<script type="text/javascript" src="editor/kindeditor.js"></script>

<script type="text/javascript">

	var serviceTelData = null;

	$(document).ready(function(e) {
		$("#btnSave").click(updateServiceTel);
		loadServiceTel();//加载服务热线
	});
	
	function loadServiceTel(){
		var requestJson = {data:{"id":1}}
		$.ajax({
	        url: '/euc/onlineops/tel/detail',
	        data:JSON.stringify(requestJson),
	        beforeSend: function(request) {
	        	var accessToken = localStorage.getItem('accessToken');
	            request.setRequestHeader("accessToken",accessToken );
	        },
	        dataType: 'JSON',
	        async: true,
	        contentType:'application/json;charset=utf-8',
	        type: 'POST',
	        success: function (result, textStatus, response) {
	        	if(result.status == '0'){
	        		var data = result.data;
	        		$("input[name='tel']").val(data.tel);
	        		$("input[name='wechat']").val(data.wechat);
	        		serviceTelData = data;
	        	}else{
	        		serviceTelData = null;
	        		alert(resutl.message);
	        	}
	        },
	        error: function () {
	        	serviceTelData = null;
	        	console.log("/euc/onlineops/tel/detail error");
	        }
	    });
	}
	
	function updateServiceTel(){
		if(serviceTelData == null){
			return;
		}
		var tel = $.trim($("input[name='tel']").val());
		if(tel == ''){
			alert("请输入热线电话！");
			return;
		}
		var wechat = $.trim($("input[name='wechat']").val());
		serviceTelData["tel"] = tel;
		serviceTelData["wechat"] = wechat;
		var requestJson = {data:serviceTelData}
		$.ajax({
	        url: '/euc/onlineops/tel/edit',
	        data:JSON.stringify(requestJson),
	        beforeSend: function(request) {
	        	var accessToken = localStorage.getItem('accessToken');
	            request.setRequestHeader("accessToken",accessToken );
	        },
	        dataType: 'JSON',
	        async: true,
	        contentType:'application/json;charset=utf-8',
	        type: 'POST',
	        success: function (result, textStatus, response) {
	        	if(result.status == '0'){
	        		var data = result.data;
	        		$("input[name='tel']").val(data.tel);
	        		$("input[name='wechat']").val(data.wechat);
	        		serviceTelData = data;
	        		alert("保存成功！");
	        	}else{
	        		alert(resutl.message);
	        	}
	        },
	        error: function () {
	        	console.log("/euc/onlineops/tel/detail edit");
	        }
	    });
	}

</script>




</head>

<body>

	<div class="place">
    	<span>位置：</span>
    	<ul class="placeul">
		    <li><a href="#">线上运营管理</a></li>
		    <li><a href="#">服务热线</a></li>
    	</ul>
    </div>

    <div class="formbody">	    
	    <div class="formtitle"><span>服务热线设置</span></div>	    
	    <ul class="forminfo">
		    <li>
		    	<label style="font-size:16px;float:left;">热线电话<b>*</b></label>
		    	<input style="float:left;" name="tel" id="addUserName" type="text" class="dfinput" placeholder="请输入热线电话"/>
		    </li>		    
		    <li></li>		    
		    <li style="display:none;">
		    	<label style="font-size:16px;float:left;">客服微信</label>			
			    <input style="float:left;" name="wechat"  type="text" class="dfinput" placeholder="请输入客服微信"/>
		    </li>
			<li></li>
		    <li>
		    	<label>&nbsp;</label>
		    	<input name="btnSave"  id="btnSave"  type="button" class="btn" value="确定"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		    </li>
	    </ul>
    </div>
</body>
</html>
